/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * <p>Project: jse2204 - Reg10
 * <p>Powered by webrx On 2022-09-15 10:51:12
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */


public class Reg10 {
    public static void main(String[] args) {
        String h = "<div><span>java18ok</span><div>12</div><div>aa678a</div><p>xxxx<div></div><div></div><div></div><div></div></p><div>aaa1</div><div>aaa2</div><div>aaa3</div><div>aaa4</div> <div>aaa</div></div>";

        Pattern p = Pattern.compile("<div>[a-zA-Z\s]*?\\d+[a-zA-Z\s]*?</div>");
        Matcher m = p.matcher(h);
        while (m.find()) {
            System.out.println("--------------------");
            System.out.println(m.group());
        }

        //修改字符串中的数字*10
        Pattern p2 = Pattern.compile("(<div>[a-zA-Z\s]*?)(\\d+)([a-zA-Z\s]*?</div>)");
        Matcher m2 = p2.matcher(h);
        String h2 = m2.replaceAll("$1$20$3");

        System.out.println(h);
        System.out.println(h2);

        System.out.println();
        //将标签清空
        Pattern p3 = Pattern.compile("(<[a-z]+?>)(.+?)(</[a-z]+?>)");
        Matcher m3 = p3.matcher(h);
        String h3 = m3.replaceAll("$1$3");
        System.out.println(h);
        System.out.println(h3);

    }
}
